package org.example.FactoryPattern;

/**
 * 测试类：验证工厂模式功能
 */
public class FactoryTest {
    public static void main(String[] args) {
        AccommodationFactory factory = new AccommodationFactory();

        // 测试创建不同类型住宿
        try {
            // 创建标准住宿
            Accommodation standard = factory.createAccommodation(1);
            standard.getAccommodationInformation();
            standard.updateCleaningStatus(true);
            standard.updateCleaningStatus(false); // 多次更新清洁状态

            // 创建豪华住宿
            Accommodation deluxe = factory.createAccommodation(2);
            deluxe.getAccommodationInformation();
            deluxe.updateCleaningStatus(false);
            deluxe.updateCleaningStatus(true); // 多次更新清洁状态

            // 测试无效类型
            factory.createAccommodation(4);
        } catch (InvalidAccommodationTypeException e) {
            System.err.println("Error: " + e.getMessage());
        }

        // 测试重复创建相同类型住宿
        try {
            Accommodation standard2 = factory.createAccommodation(1);
            standard2.getAccommodationInformation();
            standard2.updateCleaningStatus(false);

            Accommodation deluxe2 = factory.createAccommodation(2);
            deluxe2.getAccommodationInformation();
            deluxe2.updateCleaningStatus(true);
        } catch (InvalidAccommodationTypeException e) {
            System.err.println("Error: " + e.getMessage());
        }


    }
}